package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private ImageButton button;
    private Button btn2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button = findViewById(R.id.button);
        btn2=findViewById(R.id.button2);
        btn2.setOnClickListener(this);
        /*2
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getApplicationContext(),"按钮点击",Toast.LENGTH_SHORT).show();
            }
        });*/
        button.setOnClickListener(view -> Toast.makeText(getApplicationContext(),"按钮点击",Toast.LENGTH_SHORT).show());
    }
//1
    public void click(View view) {
        Toast.makeText(this,"图像点击",Toast.LENGTH_SHORT).show();
    }

    public void onClick(View view){
        Toast.makeText(this,"按钮点击",Toast.LENGTH_SHORT).show();
    }
    public void floatclick(View view) {
        Toast.makeText(this,"浮动按钮点击",Toast.LENGTH_SHORT).show();
    }
}
